package com.happy.cat.project.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
import java.util.Arrays;

import com.happy.cat.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.happy.cat.framework.aspectj.lang.annotation.Log;
import com.happy.cat.framework.aspectj.lang.enums.BusinessType;
import com.happy.cat.project.system.domain.UserManitoGategoryApply;
import com.happy.cat.project.system.service.IUserManitoGategoryApplyService;
import com.happy.cat.framework.web.controller.BaseController;
import com.happy.cat.framework.web.domain.AjaxResult;
import com.happy.cat.common.utils.poi.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.happy.cat.framework.web.page.TableDataInfo;

/**
 * 大神标签申请Controller
 *
 * @author verne
 * @date 2020-08-19
 */
@AllArgsConstructor
@RestController
@RequestMapping("/system/userManitoGategoryApply" )
@Api("大神标签申请 API")
public class UserManitoGategoryApplyController extends BaseController {

    private final IUserManitoGategoryApplyService iUserManitoGategoryApplyService;

    /**
     * 查询大神标签申请列表
     */
    @ApiOperation(value = "查询大神标签申请列表",notes = "查询大神标签申请列表",response = TableDataInfo.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserManitoGategoryApply userManitoGategoryApply)
    {
        startPage();
        LambdaQueryWrapper<UserManitoGategoryApply> lqw = new LambdaQueryWrapper<UserManitoGategoryApply>();
        if (userManitoGategoryApply.getAccountId() != null){
            lqw.eq(UserManitoGategoryApply::getAccountId ,userManitoGategoryApply.getAccountId());
        }
        if (userManitoGategoryApply.getGodGategoryId() != null){
            lqw.eq(UserManitoGategoryApply::getGodGategoryId ,userManitoGategoryApply.getGodGategoryId());
        }
        if (userManitoGategoryApply.getStatus() != null){
            lqw.eq(UserManitoGategoryApply::getStatus ,userManitoGategoryApply.getStatus());
        }
        if (userManitoGategoryApply.getApplyTime() != null){
            lqw.eq(UserManitoGategoryApply::getApplyTime ,userManitoGategoryApply.getApplyTime());
        }
        if (StringUtils.isNotBlank(userManitoGategoryApply.getApplyText())){
            lqw.eq(UserManitoGategoryApply::getApplyText ,userManitoGategoryApply.getApplyText());
        }
        if (userManitoGategoryApply.getInvalidTime() != null){
            lqw.eq(UserManitoGategoryApply::getInvalidTime ,userManitoGategoryApply.getInvalidTime());
        }
        List<UserManitoGategoryApply> list = iUserManitoGategoryApplyService.list(lqw);
        return getDataTable(list);
    }

    /**
     * 导出大神标签申请列表
     */
    @ApiOperation(value = "导出大神标签申请列表",notes = "导出大神标签申请列表",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:export')" )
    @Log(title = "大神标签申请" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(UserManitoGategoryApply userManitoGategoryApply) {
        LambdaQueryWrapper<UserManitoGategoryApply> lqw = new LambdaQueryWrapper<UserManitoGategoryApply>(userManitoGategoryApply);
        List<UserManitoGategoryApply> list = iUserManitoGategoryApplyService.list(lqw);
        ExcelUtil<UserManitoGategoryApply> util = new ExcelUtil<UserManitoGategoryApply>(UserManitoGategoryApply. class);
        return util.exportExcel(list, "userManitoGategoryApply" );
    }

    /**
     * 获取大神标签申请详细信息
     */
    @ApiOperation(value = "获取大神标签申请详细信息",notes = "获取大神标签申请详细信息",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iUserManitoGategoryApplyService.getById(id));
    }

    /**
     * 新增大神标签申请
     */
    @ApiOperation(value = "新增大神标签申请",notes = "新增大神标签申请",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:add')" )
    @Log(title = "大神标签申请" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserManitoGategoryApply userManitoGategoryApply) {
        return toAjax(iUserManitoGategoryApplyService.save(userManitoGategoryApply) ? 1 : 0);
    }

    /**
     * 修改大神标签申请
     */
    @ApiOperation(value = "修改大神标签申请",notes = "修改大神标签申请",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:edit')" )
    @Log(title = "大神标签申请" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserManitoGategoryApply userManitoGategoryApply) {
        return toAjax(iUserManitoGategoryApplyService.updateById(userManitoGategoryApply) ? 1 : 0);
    }

    /**
     * 删除大神标签申请
     */
    @ApiOperation(value = "删除大神标签申请",notes = "删除大神标签申请",response = AjaxResult.class)
    @PreAuthorize("@ss.hasPermi('system:userManitoGategoryApply:remove')" )
    @Log(title = "大神标签申请" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iUserManitoGategoryApplyService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
